//方法一：位移
class Solution {
public:
    int hammingWeight(int n) {
        int ret = 0;
        for(int i = 0 ; i <32 ; i++){
            if((n>>i) & 1){
                ret++;
            }
        }
        return ret;
    }
};
//方法二：干掉最右侧的1
class Solution {
public:
    int hammingWeight(int n) {
        int ret = 0;
        while(n){
            n &=(n-1);
            ret++;
        }
        return ret;
    }
};